package main

import (
	"git.oschina.net/yangdao/SGLisp"
	"git.oschina.net/yangdao/SGNet2"
	"git.oschina.net/yangdao/SGNet2/Server"
	. "git.oschina.net/yangdao/extlib/data_type"
	"git.oschina.net/yangdao/extlib/log"
)

var chatServer *ChatServer

func main() {
	SGLisp.InitRuntime()

	//SGNet
	dataDic := SGLisp.EvalValueFormFile(`log_config.txt`, SGLisp.MainContext).(IAssociative)
	serverLog := log.NewLogger(dataDic)
	log.DefaultLogger = serverLog
	Server.SetLog(serverLog)

	chatServer = NewChatServer()
	chatServer.Run()

	serverConfig := HashMap("port", "4399")
	sgNet := SGNet2.NewNetServer(serverConfig, serverLog)
	sgNet.SGNetMessage = chatServer.OnSessionStateMessge

	sgNet.Run()
}
